/* GUI CONVERTED from ecinplan.p (converter v1.76) Wed May 22 11:20:25 2002 */
/* ecinplan.p - ECN INCORPORATION PLANNING                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.11 $                                                          */
/*V8:ConvertMode=Report                                                       */
/* REVISION: 7.4      LAST EDIT: 08/06/93      MODIFIED BY: QZL *H013*        */
/*                               04/18/95               by: srk *H0CP*        */
/* REVISION: 8.6      LAST EDIT: 11/22/96        BY: Ashley Kurien *K00C*     */
/* REVISION: 8.6      LAST EDIT: 10/07/97        BY: John Worden   *K0LP*     */
/* REVISION: 8.6E      LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane         */
/* REVISION: 8.6E      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan        */
/* REVISION: 8.6E      LAST MODIFIED: 02/09/98   BY: Gomathy Kanagaraj *L08K* */
/* REVISION: 9.1       LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane  */
/* REVISION: 9.1       LAST MODIFIED: 08/14/00   BY: *N0KW* Jacolyn Neder     */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* $Revision: 1.11 $    BY: Jean Miller          DATE: 04/25/02  ECO: *P05V*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "2+ "}

define new shared variable site      like mrp_site.
define new shared variable effdate      like tr_effdate initial ?
   column-label "Effective".
define new shared variable curr_yn like mfc_logical format "Current/GL"
   label "Cost Method(C/G)".
define new shared variable ecmnbr like ecm_nbr.

define shared variable global_recid as recid.

define variable ecmid     like wo_lot.
define variable dbase     like si_db.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   ecmnbr
   ecmid
   dbase
   site
   effdate
with frame a width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

view frame a.

effdate = today.

{wbrp01.i}
loop-a:

repeat:

   if c-application-mode <> 'WEB' then
   update ecmnbr
      ecmid
      dbase
      site
      effdate
      curr_yn
   with frame a
   editing:

      global_recid = ?.

      if frame-field = "ecmnbr" then do:

         {mfnp05.i ecm_mstr ecm_mstr
            "(ecm_close_date = ?)"
            ecm_nbr "input ecmnbr"}

         if global_recid <> ? then do:
            recno = global_recid.
            find ecm_mstr where recid(ecm_mstr) = recno.
            global_recid = ?.
         end.

         if recno <> ? then
         display
            substring(ecm_nbr,1,8)  @ ecmnbr
            substring(ecm_nbr,9,8)  @ ecmid
            substring(ecm_nbr,17,8) @ dbase
         with frame a.

      end.

      else do:
         readkey.
         apply lastkey.
      end.

   end.

   {wbrp06.i &command = update &fields = " ecmnbr
        ecmid dbase
        site effdate
        curr_yn " &frm = "a"}

   if (c-application-mode <> 'web') or
      (c-application-mode = 'web' and
      (c-web-request begins 'data'))
   then do:

      ecmnbr = string(ecmnbr,"x(8)") + string(ecmid,"x(8)") +
               string(dbase,"x(8)").

      find ecm_mstr where ecm_nbr = ecmnbr no-lock no-error.
      if not available ecm_mstr then do:
         /* PCO Does not exist */
         {pxmsg.i &MSGNUM=2155 &ERRORLEVEL=3}
         if c-application-mode = 'WEB' then return.
         next-prompt ecmnbr with frame a.
         undo, retry.
      end.

      else if available ecm_mstr and ecm_close_date <> ? then do:
         /* PCO has been closed */
         {pxmsg.i &MSGNUM=2173 &ERRORLEVEL=3}
         if c-application-mode = 'WEB' then return.
         undo, retry.
      end.

      find si_mstr no-lock where si_site = site no-error.
      if not available si_mstr then do:
         {pxmsg.i &MSGNUM=708 &ERRORLEVEL=3}
         if c-application-mode = 'WEB' then return.
         next-prompt site with frame a.
         undo, retry.
      end.

      if available ecm_mstr and ecm_man_date <> ? and
         ecm_man_date < today
      then do:
         /* Mandatory date for this PCO is */
         {pxmsg.i &MSGNUM=2177 &ERRORLEVEL=2 &MSGARG1=ecm_man_date}
      end.

   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i &printType = "printer"
               &printWidth = 132
               &pagedFlag = " "
               &stream = " "
               &appendToFile = " "
               &streamedOutputToTerminal = " "
               &withBatchOption = "no"
               &displayStatementType = 1
               &withCancelMessage = "yes"
               &pageBottomMargin = 6
               &withEmail = "yes"
               &withWinprint = "yes"
               &defineVariables = "yes"}

   {mfphead.i}
   {gprun.i ""ecinpla1.p""}
   
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

   {mfrtrail.i}

end.

global_recid = ?.

{wbrp04.i &frame-spec = a}
